import request from '@/utils/request.js'

// 获取文章新闻推荐
export const article = (params) => {
  return request({
    url: '/v1_0/articles',
    params
  })
}

// 获取新闻详情
export const details = (id) => {
  return request({
    url: `/v1_0/articles/${id}`
  })
}

// 对文章点赞
export const addLikeArticle = (data) => {
  return request({
    url: '/v1_0/article/likings',
    method: 'post',
    data
  })
}

// 对文章不喜欢
export const delLike = (data) => request({
  method: 'post',
  url: '/v1_0/article/dislikes',
  data
})

// 取消对文章不喜欢
export const addLike = (target) => request({
  method: 'DELETE',
  url: `/v1_0/article/dislikes/${target}`
})

// 取消对文章点赞
export const delLikeArticle = (target) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/likings/${target}`
  })
}

// 收藏文章
export const hoard = (target) => {
  return request({
    method: 'post',
    url: '/v1_0/article/collections',
    data: {
      target
    }
  })
}

// 取消收藏文章
export const delHoard = (target) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/collections/${target}`
  })
}
